from django.db import models

# Create your models here.
class Permission(models.Model):
    """
    权限表
    """
    title =  models.CharField(max_length=32,verbose_name='标题')
    url = models.CharField(max_length=128,verbose_name='含正则的url')
    def __str__(self):
        return self.title

class Roles(models.Model):
    """
    角色
    """
    title = models.CharField(max_length=32,verbose_name='角色名称')
    permissions = models.ManyToManyField(Permission,verbose_name='拥有的权限',to='Permission',blank=True)
    def __str__(self):
        return self.title

class UserInfo(models.Model):
    name =models.CharField(max_length=32,verbose_name='用户名')
    password = models.CharField(max_length=64,verbose_name='密码')
    Email= models.CharField(max_length=32,verbose_name='邮箱')
    roles = models.ManyToManyField(Roles,verbose_name='所拥有的角色',to='Roles',blank=True)
    def __str__(self):
        return self.name